package com.bdqn.pojo;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 系统用户实体
 *
 * @author LILIBO
 * @since 2021-05-14
 */
public class SysUser implements java.io.Serializable{

    private Integer id; //id
    private String account; //用户编码
    private String realName; //真实名称
    private String password; //用户密码
    private Integer sex;  //性别
    private Date birthday;  //出生日期
    private String phone;   //电话
    private String address; //地址
    private Integer roleId;    //用户角色ID
    private Integer createdUserId;   //创建者
    private Date createdTime; //创建时间
    private Integer updatedUserId;     //更新者
    private Date updatedTime;   //更新时间
    private String userRoleName;//角色名称
    private String idPicPath;//身份证照片
    private String workPicPath;//工作证照片
    private Integer age;//年龄
    private String roleName; //用户角色名称

    public SysUser() {
    }

    public SysUser(int id, String realName, int sex, Date birthday, String phone, String address, int roleId, Integer updatedUserId) {
        this.id = id;
        this.realName = realName;
        this.sex = sex;
        this.birthday = birthday;
        this.phone = phone;
        this.address = address;
        this.roleId = roleId;
        this.updatedUserId = updatedUserId;
    }

    public SysUser(String account, String realName, String password, int sex, Date birthday, String phone, String address, int roleId,
                   Integer createdUserId, String idPicPath, String workPicPath) {
        this.account = account;
        this.password = password;
        this.realName = realName;
        this.sex = sex;
        this.birthday = birthday;
        this.phone = phone;
        this.address = address;
        this.roleId = roleId;
        this.createdUserId = createdUserId;
        this.idPicPath = idPicPath;
        this.workPicPath = workPicPath;
    }

    public SysUser(int id, String account, String realName, String password, int sex, String phone, String address, int roleId,
                   Integer createdUserId, Date createdTime,int updatedUserId,Date updatedTime) {
        this.id = id;
        this.account = account;
        this.password = password;
        this.realName = realName;
        this.sex = sex;
        this.phone = phone;
        this.address = address;
        this.roleId = roleId;
        this.createdUserId = createdUserId;
        this.createdTime = createdTime;
        this.updatedUserId = updatedUserId;
        this.createdTime = updatedTime;
    }

    public String getRoleName() {
        return roleName;
    }

    public String getIdPicPath() {
        return idPicPath;
    }

    public void setIdPicPath(String idPicPath) {
        this.idPicPath = idPicPath;
    }

    public String getWorkPicPath() {
        return workPicPath;
    }

    public void setWorkPicPath(String workPicPath) {
        this.workPicPath = workPicPath;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public SysUser(String account, String realName, String password, int sex, String birthdayStr, String phone,
                   String address, int roleId, int createdUserId, String userRoleName) throws ParseException {
        this.account = account;
        this.realName = realName;
        this.password = password;
        this.sex = sex;
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Date date = format.parse(birthdayStr);
        this.birthday = date;
        this.phone = phone;
        this.address = address;
        this.roleId = roleId;
        this.createdUserId = createdUserId;
        this.userRoleName = userRoleName;
    }


    public String getUserRoleName() {
        return userRoleName;
    }

    public void setUserRoleName(String userRoleName) {
        this.userRoleName = userRoleName;
    }

    public Integer getAge() {
      /*long time = System.currentTimeMillis()-birthday.getTime();
      Integer age = Long.valueOf(time/365/24/60/60/1000).IntegerValue();*/
        Date date = new Date();
        Integer age = date.getYear() - birthday.getYear();
        return age;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public String getRealName() {
        return realName;
    }

    public void setRealName(String realName) {
        this.realName = realName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Integer getSex() {
        return sex;
    }

    public void setSex(Integer sex) {
        this.sex = sex;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public Integer getRoleId() {
        return roleId;
    }

    public void setRoleId(Integer roleId) {
        this.roleId = roleId;
    }

    public Integer getCreatedUserId() {
        return createdUserId;
    }

    public void setCreatedUserId(Integer createdUserId) {
        this.createdUserId = createdUserId;
    }

    public Date getCreatedTime() {
        return createdTime;
    }

    public void setCreatedTime(Date createdTime) {
        this.createdTime = createdTime;
    }

    public Integer getUpdatedUserId() {
        return updatedUserId;
    }

    public void setUpdatedUserId(Integer updatedUserId) {
        this.updatedUserId = updatedUserId;
    }

    public Date getUpdatedTime() {
        return updatedTime;
    }

    public void setUpdatedTime(Date updatedTime) {
        this.updatedTime = updatedTime;
    }

    public void setAge(Integer age) {
        this.age = age;
    }
}
